<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../node_modules/vue/dist/vue.js"></script>
</head>

<body>
    <div id="app">
        <alert-box :list = 'list'>
            <!-- <h1 slot="myslot">具名插槽内容</h1> -->
            <!-- <template slot="myslot">
                <h1>
                    具名插槽内容
                </h1>
            </template>
            插槽内容 -->

            <!-- 作用域插槽 -->
            <template slot-scope="slotProps"> 
                <strong v-if="slotProps.info.id == 2">{{slotProps.info.name}}</strong>
                <span v-else>{{slotProps.info.name}}</span>
               
            </template>
        </alert-box>
    </div>
    <script>
        var vm = new Vue({
            el: '#app',
            data() {
                return {
                    list: [{
                        id: 1,
                        name: 'apple'
                    }, {
                        id: 2,
                        name: 'orange'
                    }, {
                        id: 3,
                        name: 'banana'
                    }]
                }
            },
            methods: {

            },
            components: {
                'alert-box': {
                    template: `<div>
                            <li v-for = 'item in list' :key='item.id'>
                                <slot :info = 'item'>{{item.name}}</slot>    
                            </li>
                        </div>`,
                    props:['list']
                }
            }
        })


    </script>
</body>

</html>